The present invention relates to an apparatus and a method of encoding moving picture signals. Particularly, this invention relates to an apparatus and a method of encoding moving picture signals with code amount control for real time variable-bit rate encoding.
Moving picture Experts Group (MPEG)-2 has been established as the international standards for encoding moving picture signals, such as, TV signals.
MPEG-2 offers motion-compensated prediction and transform encoding as its two technical features.
Motion-Compensated Prediction: A frame of moving picture is divided into 16×16 blocks called macroblocks. For each macroblock, a motion amount called a motion vector is detected between the present picture frame to be coded and a reference frame which comes before or after the present picture frame on the time base by a predetermined number of frames. An encoded picture is generated on the basis of the reference frame and the motion vector.
Transform Encoding: A picture frame or a predictive error signal generated by motion-compensated prediction is compressed by Discrete Cosine Transform (DCT) as an orthogonal transforming technique.
Motion-compensated prediction in MPEG-2 generates moving pictures of three types; I-pictures (intra-coded pictures), P-pictures (predictive-coded pictures) and B-pictures (bidirectionally predictive-coded pictures).
I-pictures are subjected to DCT as they are, on the other hand, for P- and B-pictures, predictive error signals are subjected to DCT, for generating DCT coefficients.
The DCT coefficients are quantized with a quantization scale factor under code amount control.
The quantized DCT coefficients are encoded by variable-length encoding, with auxiliary data, such as, motion vectors, to generate a bit stream which will be an output coded data via buffer.
A quantization scale factor is determined by code amount control according to the amount of bit stream passing through the buffer.
The quantized DCT coefficients are further subjected to de-quantization and Inverse-DCT (IDCT) for local decoding, and stored in a frame memory per macroblock for motion-compensated prediction.
The amount of codes (bit rate) generated for each predetermined period in MPEG-2 is not constant due to variable-length encoding.
In order to overcome this problem, MPEG-2 has offered techniques of quantization scale factor adjustments per macroblock for achieving constant bit rate.
MPEG-2 Test Model 5 has proposed a technique of constant bit rate control for generating a constant amount of codes per Group of Pictures (GOP), for achieving constant transfer rate.
This technique, however, allocates almost the same amount of codes over the entire portions of a moving picture sequence. The constant amount code allocation causes deterioration of images due to insufficient code allocation to images of complex scenes which have a lot of data, on the other hand, unnecessary code amount allocation to images of plain scenes which have a few data.
This technique is, therefore, not a suitable bit rate control method for DVD-Video having a variable-transfer rate control function, for instance.
A technique of variable-bit rate control overcomes the problem of constant bit rate control for DVD-Videos, and is disclosed in Japanese Unexamined-Patent Publication No. 1994(6)-141298.
In this technique, an input moving picture is subjected to temporal (first) encoding with a fixed quantization scale factor, and the amount of generated codes is counted per specific period of time. A target transfer rate for each portion, such as, a frame, of the input moving picture is set on the basis of the counted code amount so that the amount of codes of the entire input moving picture becomes a specific value.
The input moving picture is then subjected to actual (second) encoding with bit rate adjustments so that a bit rate for each portion of the input moving picture becomes the target transfer rate.
This variable-bit rate control, however, requires two time-encoding, that is, temporal and actual encoding, thus not achieving real time control. The two time-encoding is called two pass-encoding hereinafter.
Contrary to such two pass-encoding, one pass (time)-encoding with variable-bit rate control has been introduced by Japanese Unexamined-Patent Publication No. 1998(10)-164577 for almost real time moving picture encoding.
This technique obtains picture complexity calculated by multiplying the amount of codes encoded so far and an average quantization scale factor for each picture. The ratio of the present picture complexity to average past picture complexity is used for deciding a target code amount or target quantization scale factor for variable-bit rate control.
Another technique of one pass-encoding with variable-bit rate control is disclosed in Unexamined-Patent Publication No. 1998(10)-302396.
This technique examines difficulty in encoding per predetermined period for obtaining a temporal code amount to be allocated for each predetermined period with reference to a standard encoding difficulty and code amount to be allocated.
The temporal code amount to be allocated is changed to an actual code amount to be allocated by comparing a code amount to be allocated Bav which is given by encoding with a fixed code amount to be allocated bav decided under actual storage capacity of a storage medium and a total actual code amount Bgen encoded so far; and allowing a code amount to be allocated equal to or larger than bav when Bav-bav is positive, thus achieving recording of a certain length of moving picture on a storage medium so that a total code amount generated for the certain length of moving picture is smaller than the storage capacity of the storage medium.
This one pass-encoding with variable-bit rate control also has the following disadvantages:
In this technique, the present picture complexity is obtained by temporarily encoding the present picture which will be encoded from now on or the picture complexity of the picture encoded just before and of the same picture-type is used as the present picture complexity without temporal encoding.
The one pass-encoding thus causes delay in encoding if it is temporal encoding and requires a bulk of circuitry.
Moreover, even though without such temporal encoding, when picture complexity varies on pictures, in other words, scene change occurs just before the present picture to be encoded, the picture complexity decided just before (the same picture-type) used as the present picture complexity would be different from actual picture complexity. This causes improper code amount allocation.
Different from the two pass-encoding, the one pass-encoding executes bit rate control without detecting how picture complexity varies for an input moving picture sequence.
This technique thus executes encoding under assumption that overall change in picture complexity of an input moving picture sequence is similar to that of average picture complexity of typical pictures.
This also causes improper code amount allocation, for example, for a moving picture sequence with monotonic increase in picture complexity (for example, the former part of the moving picture sequence is constituted by simple scenes easy for encoding and the latter part gradually complex scenes hard for encoding).
Code amounts to be allocated for such latter part go beyond a target code amount. Using-up of an excess code amount to be allocated (the total of differences between a target code amount and each generated code amount) for the simple scenes easy for encoding abruptly decreases code amounts to be allocated to cause picture degradation for, particularly, complex scenes hard for encoding, compared to encoding with fixed bit rate control.
On the other hand, for a moving picture sequence with the former part of complex scenes hard for encoding and the latter part of scenes having average picture complexity, code amounts are allocated for the latter part with reference to the picture complexity of the former part.
This causes allocation of extremely small amounts of code to the latter part of average scenes with picture degradation, thus results in amount of codes generated for the moving picture sequence extremely smaller than a target code amount, with ineffective usage of a storage medium.
This technique is capable of allocation of code amounts in which, when an allocated code amount is smaller than a predetermined code amount to be allocated bav decided on the basis of actual storage capacity of a storage medium, after this, code amount allocation beyond bav is made possible.
This achieves improvement in subjective picture quality for a moving picture sequence with the former part of simple scenes easy for encoding and the latter part of complex scenes hard for encoding.
Contrary to this, for a moving picture sequence with the former part of complex scenes hard for encoding and the latter part of simple scenes easy for encoding, improvement in subjective picture quality for the former part is impossible and an excess amount of codes is generated for the latter part when encoding is complete, with ineffective usage of a storage medium.